<?xml version="1.0" encoding="UTF-8"?>
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
   xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
   xmlns:f="http://xmlns.jcp.org/jsf/core"
   xmlns:h="http://xmlns.jcp.org/jsf/html"
   xmlns:p="http://primefaces.org/ui"
   xmlns:c="http://xmlns.jcp.org/jsp/jstl/core"
   template="/WEB-INF/templates/default.xhtml">
   
   	<f:metadata>
	   	<f:viewParam name="serviceSupplierId" value="#{serviceSupplierHome.id}"></f:viewParam>
	   	<f:event listener="#{serviceSupplierHome.initConversation()}" type="preRenderView"></f:event>
	   	<f:viewParam name="moduleName" value="审核中介用户"></f:viewParam>
   	</f:metadata>
   	
    <ui:define name="head">
   		<script type="text/javascript">
			function start() {
			    PF('statusDialog').show();
			}
			 
			function stop() {
			    PF('statusDialog').hide();
			}
		</script>
   		<style type="text/css">
   			.reasonLabel{
   				padding-left:10px;
   				width:20%;
   				text-align:left;
   			}
   			.reasonText{
   				width:75%;
   			}
   		</style>
    </ui:define>
    
   	<ui:define name="content">
   
		<h:form id="editForm">  
			<h:panelGrid columns="2" style="width:100%;color:red" columnClasses="reasonLabel,reasonText"  rendered="#{serviceSupplierHome.instance.historyRejectRecords.size() > 0}">
				<p:outputLabel>上次驳回原因:</p:outputLabel>
				<h:outputText value="#{serviceSupplierHome.instance.historyRejectRecords.get(0).reason}" />
			</h:panelGrid>       
			<p:panel id="panel" header="审核中介基本信息" style="margin-bottom:10px;">
		       <p:messages id="messages" closable="true"><p:autoUpdate/></p:messages>
		        
		        <ui:include src="../template/include/supplierBaseInfo.xhtml" />
			</p:panel>
			
			<p:panel header="主营业务" style="margin-bottom:10px;">
				<p:repeat var="_business" value="#{serviceSupplierHome.instance.mainBusinesses}" varStatus="_status">
	        		<p:panel header="主营业务#{_status.index + 1}">
	        			<p:panelGrid columns="2" columnClasses="label, value" style="width: 100%">
	        				<p:outputLabel value="服务事项" />	
							<h:outputText 
									   value="#{_business.agentService.name}" />
									   
							<p:outputLabel value="服务时限承诺" />	
							<h:outputText 
									   value="#{_business.commitOfTime}" />
									   
							<p:outputLabel value="服务收费承诺" />	
							<h:outputText 
									   value="#{_business.commitOfPrice}" />
									   
							<p:outputLabel value="服务质量承诺" />	
							<h:outputText 
									   value="#{_business.commitOfQuality}" />
	        			</p:panelGrid>
	        			
	        			<p:dataTable id="uploadedImages#{_business.bussinessIndex}" value="#{_business.images}" var="_attr" rowIndexVar="_row" emptyMessage="无已上传图片">
						
							<p:column headerText="文件名">
								<h:outputText value="#{_attr.filename}" />
							</p:column>
												
							<p:column headerText="大小（MB）" style="text-align: right;">
								<h:outputText value="#{_attr.filesize / 1024 / 1024}">	
									<f:convertNumber minFractionDigits="2" groupingUsed="true" />
								</h:outputText>
							</p:column>
							
							<p:column headerText="预览">
								<div id="imgsPreview_#{_attr.id}">
									<img data-original="#{attachmentUtils.getFullPath( _attr )}" src="#{attachmentUtils.getFullPath( _attr )}" width="240"/>
								</div>
							</p:column>
							
						</p:dataTable>
	        		</p:panel>
	        	</p:repeat>
			</p:panel>
			<p:panel header="相关附件" style="margin-bottom:10px;">   
				<p:panel id="uploadedAttachments">
					<ul>
						<p:repeat var="_attachment"
							value="#{serviceSupplierHome.instance.attachments}">
							<li style="line-height:40px;">
								<h:outputText value="#{_attachment.filename}" />
								<p:commandButton style="margin-left:10px;" value="下载" ajax="false"  icon="ui-icon-arrowthick-1-s">
							        <p:fileDownload value="#{fileDownloadView.download(_attachment)}" />
							    </p:commandButton>
							</li>
						</p:repeat>
					</ul>
				</p:panel>
			</p:panel>
			<p:commandButton action="#{serviceSupplierHome.audit}" value="审核通过" ajax="false" />
			<p:commandButton oncomplete="PF('rejectDialog').show();" value="驳回" immediate="true"></p:commandButton>			
			<p:commandButton action="#{serviceSupplierHome.cancel()}" value="取消" immediate="true"></p:commandButton>			
		</h:form>

		<p:dialog
			id="imageDialog"
			widgetVar="imageDialog"
			modal="true"
			width="60%"
		>
			<f:facet name="header">
				营业执照
			</f:facet>
			<p:panel style="text-align: center;">
				<div id="imgsPreview" >
					<img  data-original="#{attachmentUtils.getFullPath(certHome.instance.serviceSupplier.businessLicenseImages[0])}" src="#{attachmentUtils.getFullPath(certHome.instance.serviceSupplier.businessLicenseImages[0])}"  width="240"/>
				</div>	
			</p:panel>
		</p:dialog>
		
		<p:dialog id="rejectDialog" widgetVar="rejectDialog">
			<f:facet name="header">
				驳回原因
			</f:facet>
			<h:form>
				<p:panelGrid columns="2">
					<p:outputLabel for="reason" value="驳回原因"></p:outputLabel>
					<p:inputTextarea
						id="reason"
						value="#{rejectRecordHome.instance.reason}"
						required="true"
						cols="80"
						rows="5"
					></p:inputTextarea>
				</p:panelGrid>
								
				<p:commandButton action="#{serviceSupplierHome.reject}" value="驳回" ajax="false" />
				<p:commandButton oncomplete="PF('rejectDialog').hide();" value="取消" immediate="true"></p:commandButton>
			</h:form>
		</p:dialog>
	</ui:define>
</ui:composition>
